cmake_minimum_required(VERSION 3.13.0)

set(CMAKE_BUILD_TYPE DEBUG)
set(LDSCRIPT ${CMAKE_CURRENT_LIST_DIR}/STM32G030K6Tx_FLASH.ld)
include(cortex.cmake)

project(mouseboard_display
    LANGUAGES C ASM
)

add_executable(${PROJECT_NAME}.elf)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/cmsis)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/hal)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/driver)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/app)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/rtos)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/rtt)

add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
    COMMAND ${SIZE} ${PROJECT_NAME}.elf)

add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
    COMMAND ${OBJCOPY} -O ihex ${PROJECT_NAME}.elf ${PROJECT_NAME}.hex)